<template>
  <div>
        <el-table :data="npcTaskItemData" border style="width: 100%" max-height="250"  :default-sort="{prop: 'vendorCode', order: 'descending'}">
            <el-table-column prop="materialNo" align="center" label="物料编码" width="150"></el-table-column>
            <el-table-column prop="materialName" align="center" label="物料名称" width="200"></el-table-column>
            <el-table-column prop="unit" align="center" label="计量单位" width="100"></el-table-column>
            <el-table-column prop="sampleNumber" align="center" label="打样数量" width="100"></el-table-column>
            <el-table-column prop="confirmStatus" align="center" :formatter="confirmStatusStr" label="确认状态" width="100"></el-table-column>
            <el-table-column prop="existRefuse" align="center" :formatter="existRefuseStr" label="是否含驳回项" width="150"></el-table-column>
            <el-table-column prop="completeStatus" align="center" :formatter="completeStatusStr" label="打样状态" width="150"></el-table-column>
            <el-table-column prop="figureNumber" align="center" label="图号" width="200"></el-table-column>
            <el-table-column prop="requireTime" align="center" label="样品提供日期" width="200"></el-table-column>
            <!-- <el-table-column prop="drawingFileName" align="center" label="图纸" width="300"></el-table-column>
            <el-table-column prop="checkingFileName" align="center" label="检验标准" width="300"></el-table-column> -->
            <el-table-column prop="checkingFileName" align="center" label="检验标准" width="200">
              <template slot-scope="scope">
                <el-button type="text" @click="downloadFiles(scope.row.checkingFileUrl,scope.row.checkingFileName)">{{scope.row.checkingFileName}}</el-button>
              </template>
            </el-table-column>
            <el-table-column prop="drawingFileName" align="center" label="图纸" width="200">
              <template slot-scope="scope">
                <el-button type="text" @click="downloadFiles(scope.row.drawingFileUrl,scope.row.drawingFileName)">{{scope.row.drawingFileName}}</el-button>
              </template>
            </el-table-column>
        </el-table>
  </div>
</template>
<script>
  export default {
    data() {
      return {
        // 初始化表格数据
        npcTaskItemData: []
      };
    },
    mounted() {
      this.query();
    },
    methods: {
      query(){
        this.axios.post(this.lib.config.host.vendorDlv + "/vendormgt/npc/npcTaskItem/query/" + this.$route.query.npcTaskId)
        .then((response)=> {
            this.npcTaskItemData = response.data;
        })
        .catch((error)=> {
            console.log(error);
        });
      },
      confirmStatusStr(row,column){
        if(row.confirmStatus == 0){
          return '未确认'
        } else {
          return '已确认'
        }
      },
      existRefuseStr(row,column){
        if(row.existRefuse == 0){
          return '否'
        } else {
          return '是'
        }
      },
      completeStatusStr(row,column){
        if(row.existRefuse == 0){
          return '未完成'
        } else {
          return '已完成'
        }
      },
       // 下载附件
      downloadFiles(filePath,fileName){
        this.downloadFile(filePath, fileName);
      }
    }
  }
</script>